package labox.innovation.gameserver.network.serverpackets;

import java.util.List;

import javolution.util.FastList;

/**
 *
 * MagicEffectIcons
 * format   h (dhd)
 *
 * @version $Revision: 1.3.2.1.2.6 $ $Date: 2005/04/05 19:41:08 $
 */
public class AbnormalStatusUpdate extends L2GameServerPacket {
	
	private static final String _S__97_ABNORMALSTATUSUPDATE = "[S] 85 AbnormalStatusUpdate";

	private List<Effect> _effects;

	private class Effect {
		protected int _skillId;

		protected int _level;

		protected int _duration;

		public Effect(int pSkillId, int pLevel, int pDuration) {
			_skillId = pSkillId;
			_level = pLevel;
			_duration = pDuration;
		}
	}

	public AbnormalStatusUpdate() {
		_effects = new FastList<Effect>();
	}

	public void addEffect(int skillId, int level, int duration) {
		if (skillId == 2031 || skillId == 2032 || skillId == 2037 || skillId == 26025 || skillId == 26026)
			return;
		_effects.add(new Effect(skillId, level, duration));
	}

	@Override
	protected final void writeImpl() {
		writeByte(0x85);

		writeInt(_effects.size());

		for (Effect temp : _effects) {
			writeInt(temp._skillId);
			writeInt(temp._level);

			if (temp._duration == -1)
				writeInt(-1);
			else
				writeInt(temp._duration / 1000);
		}
	}

	/* (non-Javadoc)
	 * @see net.sf.l2j.gameserver.serverpackets.ServerBasePacket#getType()
	 */
	@Override
	public String getType() {
		return _S__97_ABNORMALSTATUSUPDATE;
	}
}
